package com.biubiux2.message;

/**
 * @author noexcs
 * @since 8/10/2022 2:11 AM
 */
public class MessageType {

    public static final int LOGIN_REQUEST = 0;

    public static final int USER_MSG = 1;

    public static final int ERROR = 2;

    public static final int LOGIN_RESPONSE = 3;

    public static final int HEARTBEAT_PING = 4;

    public static final int HEARTBEAT_PONG = 5;

    public static final int CLIENT_PUBLIC_KEY = 6;

    public static final int SERVER_SECRET_KEY = 7;

    public static final int FOR_TEST = 8;

    public static final int TEST_RESPONSE = 9;

    public static final int LOGOUT = 10;

    public static final int RECONNECT = 11;

    public static final int RECONNECT_SUCCESS_RESPONSE = 12;

    public static final int RECONNECT_FAIL_RESPONSE = 13;

    public static final int RELOGIN = 14;

    public static final int MODIFY_USER_DATA = 15;

    /**
     * 是否为必须收到响应才能发送后续请求数据的数据类型
     * 这种类型请求与响应都包含消息id
     *
     * @param type {@code MessageType}
     * @return
     */
    public static boolean isSynchronous(int type) {
        return type == LOGIN_REQUEST || type == FOR_TEST;
    }

    public static boolean isSynchronousResponse(int type) {
        return type == LOGIN_RESPONSE || type == TEST_RESPONSE;
    }
}
